What is latest-version?
The 'latest-version' npm package allows you to fetch the latest version of an npm package from the npm registry. It is useful for checking if a package is up-to-date or for automating updates in your projects.
What are latest-version's main functionalities?
Fetch Latest Version
This feature allows you to fetch the latest version of a specified npm package. In the code sample, it fetches the latest version of the 'npm' package.
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('npm'));
//=> '7.24.0'
})();
Fetch Latest Version with Specific Tag
This feature allows you to fetch the latest version of a specified npm package with a specific tag. In the code sample, it fetches the latest beta version of the 'npm' package.
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('npm', { version: 'beta' }));
//=> '8.0.0-beta.0'
})();
Other packages similar to latest-version
package-json
The 'package-json' npm package allows you to get metadata of an npm package, including its latest version. It provides more detailed information compared to 'latest-version', such as dependencies, maintainers, and more.
npm-check-updates
The 'npm-check-updates' npm package allows you to find newer versions of dependencies than what your package.json allows. It is more focused on updating dependencies in your project rather than just fetching the latest version.
semver
The 'semver' npm package provides utilities for working with semantic versioning. While it does not fetch the latest version from the npm registry, it can be used to compare versions and validate version strings.
latest-version
Get the latest version of an npm package
Fetches the version directly from the registry instead of depending on the massive npm module like the latest module does.
Install
npm install latest-version
Usage
import latestVersion from 'latest-version';
console.log(await latestVersion('ava'));
console.log(await latestVersion('@sindresorhus/df'));
console.log(await latestVersion('npm', {version: 'latest-5'}));
This package exposes the version
, registryUrl
, and omitDeprecated
options from package-json
, as well as the PackageNotFoundError
and VersionNotFoundError
errors.
Related